<?php 
class RegisterController extends Controller{
	private $model;
	public function __construct(){
		parent::__construct();
		$this->model=K("User");
		
	}
	public function index(){
		if(IS_POST){
//			判断验证码
$code=$_POST['code'];
if(strtoupper($code)!=$_SESSION['code']){
	$this->error("验证码错误");
	
}
//用户名
$account=$_POST['account'];

$acData=K("User")->where("account='{$account}'")->find();

	if($acData){
		$this->error("用户名已存在");
		
	}
	if(!$this->model->addData()){
		$this->error($this->model->error);
		
	};


    $this->success("注册成功",U("Index/Index/index"));
		}
		$this->display();
		
	}
	public function code(){
		$code=new Code;
		$code->show();
	}

}
	?>